package client;

import java.util.ArrayList;

import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class FilterPanel extends JList {

	private ArrayList<String> options;
	
	public FilterPanel(){
		options = new ArrayList<String>();
		options.add("One");
		options.add("Two");
		options.add("Three");
		options.add("Four");
		this.setListData(options.toArray());
	}

	public void setData(ArrayList<String> options) {
		this.options.clear();
		this.options.addAll(options);
	}

	public void filter(String with) {
		ArrayList<String> values = new ArrayList<String>();
		for (String text : options) {
			if (text.isEmpty()||text.contains(with)) {
				values.add(text);
			}
		}
		this.setListData(values.toArray());
	}

}
